package book;

public class TestSeqStackly {

	public static void main(String[] args) {
		test01();

	}
	private static void test01() {
		//创建一个空栈
		SeqStackly myStackly = new SeqStackly();
		int test[] = {1,3,5,7,9};
		int n =5;
		try {
			//依次将长度为5的整形数组中的书转换为Integer类型入栈
			for(int i =0;i<n;i++) {
				myStackly.push(new Integer(test[i]));
			}
			//获取栈顶元素
			System.out.println("当前栈顶元素为："+myStackly.getTop());
			System.out.println("元素出栈序列为：");
			while(myStackly.notEmpty()) {
				//判断栈是否为空
				System.out.println(myStackly.pop());//逐个出栈
				
			}
		}catch(Exception e) {
			System.out.println(e.getMessage());
		}
	}

}
